Skip to content

Conversation

@ulfalizer
Copy link
Contributor

@ulfalizer ulfalizer commented Nov 16, 2019

Fixes: #20673

Main fix:

kconfig: Make FLASH_LOAD_OFFSET/SIZE non-configurable when DT is used

Having FLASH_LOAD_OFFSET and FLASH_LOAD_SIZE always configurable froze
their values at 0 when BOOTLOADER_MCUBOOT was enabled in menuconfig,
when instead the values from /chosen/zephyr,code-partition in devicetree
should be used. BOOTLOADER_MCUBOOT selects USE_CODE_PARTITION, which is
a flag to use the devicetree information.

To fix it, only make FLASH_LOAD_OFFSET and FLASH_LOAD_SIZE configurable
when USE_CODE_PARTITION is disabled. It looks like no configuration
files set them at the moment.

See the added documentation in
https://github.com/zephyrproject-rtos/zephyr/pull/20722 for an
explanation of why this happens. This bit novalisek in
https://github.com/zephyrproject-rtos/zephyr/issues/20673.

Fixes: #20673

Documentation improvements and cleanups:

kconfig: Improve USE_CODE_PARTITION prompt and help string

The prompt and help string for USE_CODE_PARTITION were too terse and
didn't make it clear that it's related to devicetree, which confused me.
Spell things out in more detail.

Unless the meaning of a symbol is completely obvious from context, aim
for at least a few sentences of help text. Think about what would be
confusing for someone coming at it without much context.
kconfig: Rename USE_CODE_PARTITION to USE_DT_CODE_PARTITION

USE_CODE_PARTITION is a bit vague as a symbol name ("use code partition
how?"). Rename it to USE_DT_CODE_PARTITION to make it clearer that it's
about devicetree.

This would break any third-party configuration files that set it, but
it'll generate an error since kconfig.py promotes warnings to errors, so
it's probably not a big deal.
kconfig: Factor out HAS_FLASH_LOAD_OFFSET dependency

Use a top-level 'if' instead of three separate 'depends on'. They're
exactly equivalent (top-level 'if's are just a shorthand for adding
'depends on' to each item within the 'if').

Having FLASH_LOAD_OFFSET and FLASH_LOAD_SIZE always configurable froze
their values at 0 when BOOTLOADER_MCUBOOT was enabled in menuconfig,
when instead the values from /chosen/zephyr,code-partition in devicetree
should be used. BOOTLOADER_MCUBOOT selects USE_CODE_PARTITION, which is
a flag to use the devicetree information.

To fix it, only make FLASH_LOAD_OFFSET and FLASH_LOAD_SIZE configurable
when USE_CODE_PARTITION is disabled. It looks like no configuration
files set them at the moment.

See the added documentation in
zephyrproject-rtos#20722 for an
explanation of why this happens. This bit novalisek in
zephyrproject-rtos#20673.

Fixes: zephyrproject-rtos#20673

Signed-off-by: Ulf Magnusson <[email protected]>
The prompt and help string for USE_CODE_PARTITION were too terse and
didn't make it clear that it's related to devicetree, which confused me.
Spell things out in more detail.

Unless the meaning of a symbol is completely obvious from context, aim
for at least a few sentences of help text. Think about what would be
confusing for someone coming at it without much context.

Signed-off-by: Ulf Magnusson <[email protected]>
USE_CODE_PARTITION is a bit vague as a symbol name ("use code partition
how?"). Rename it to USE_DT_CODE_PARTITION to make it clearer that it's
about devicetree.

This would break any third-party configuration files that set it, but
it'll generate an error since kconfig.py promotes warnings to errors, so
it's probably not a big deal.

Signed-off-by: Ulf Magnusson <[email protected]>
Use a top-level 'if' instead of three separate 'depends on'. They're
exactly equivalent (top-level 'if's are just a shorthand for adding
'depends on' to each item within the 'if').

Signed-off-by: Ulf Magnusson <[email protected]>
@carlescufi carlescufi added the bug The issue is a bug, or the PR is fixing a bug label Nov 18, 2019
Copy link
Contributor

@nvlsianpu nvlsianpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look fine.
For future; Would be great if PR description was an abstract instead of commit messages conglomerate :D

Copy link
Member

@ioannisg ioannisg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link
Contributor

@mbolivar mbolivar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@novalisek
Copy link

see my comment at #20673 (comment) I think it is not working properly when enabling and disabling mcuboot again

@ioannisg
Copy link
Member

Anyone outside Nordic would like to review this? @galak @MaureenHelm

@ulfalizer
Copy link
Contributor Author

see my comment at #20673 (comment) I think it is not working properly when enabling and disabling mcuboot again

Posted a comment there that explains it.

@sslupsky
Copy link
Contributor

Hi, I stumbled on this PR and issue #20673 . I had been struggling to get the code-partition setting in devicetree to actually relocate my code. I had to manually include

CONFIG_FLASH_BASE_ADDRESS=0x2000

in my proj.conf to locate my code past my boot loader (uf2-samd). Then I found this issue searching "code-partition". Turns out, adding

CONFIG_USE_CODE_PARTITION

works. So I added that to my board's defconfig.

The documentation about code-partition I referred to is here: https://github.com/zephyrproject-rtos/zephyr/blob/master/doc/guides/dts/flash_partitions.inc. I think it would be helpful if this page was updated to explain that CONFIG_USE_CODE_PARTITION needs to be set so that the code-partition devicetree setting is used.

@ioannisg
Copy link
Member

Moving this to 2.2, to get reviews outside nordic

@nashif nashif merged commit fd9981a into zephyrproject-rtos:master Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards area: Kconfig bug The issue is a bug, or the PR is fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

guiconfig not working properly?